package com.xll.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.xll.entity.BloodPressure;
import com.xll.entity.FoodType;
import com.xll.mapper.BloodPressureMapper;
import com.xll.service.BloodPressureService;
import com.xll.utils.PageResult;
import com.xll.utils.QueryInfo;
import com.xll.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class BloodPressureServiceImpl  implements BloodPressureService {


    @Autowired
    private BloodPressureMapper bloodPressureMapper;



    @Override
    public Result delete(Long id) {
        bloodPressureMapper.delete(id);
        return Result.success("血压记录删除成功");
    }

    @Override
    public Result update(BloodPressure bloodPressure) {
        bloodPressureMapper.update(bloodPressure);
        return  Result.success("血压记录更新成功");
    }

    @Override
    public Result findPage(QueryInfo queryInfo) {
        PageHelper.startPage(queryInfo.getPageNumber(), queryInfo.getPageSize());
        Page<BloodPressure> page = bloodPressureMapper.findPage(queryInfo.getQueryString());
        return Result.success("血压记录查询成功", new PageResult(page.getTotal(), page.getResult()));
    }

    @Override
    public Result insert(BloodPressure bloodPressure) {
        bloodPressureMapper.insert(bloodPressure);
        return  Result.success("血压记录插入成功");
    }
}
